# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# openUBMC is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#         http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

"""Pass 语句节点"""

import ast
from dataclasses import dataclass, field
from .base import IRStmt


@dataclass
class IRPass(IRStmt):
    """Pass 语句 IR 节点

    表示 Python 的 pass 语句，在 C++ 中生成空语句
    """

    node_type: str = "pass"
    source_line: int = field(default=0)

    def build_from_ast(self, node: ast.Pass) -> None:
        """从 AST 节点构建

        Args:
            node: ast.Pass 节点
        """
        self.source_line = node.lineno if hasattr(node, "lineno") else 0

    def __str__(self) -> str:
        """字符串表示"""
        return "pass"
